﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using GameEngine.Model.Data;
using GameEngine.Model.Data.implementation;
using GameEngine.Clients.Silverlight.View.Components;
using MapEngine;
using System.Collections.Generic;

namespace SilverlightResources
{
    public class MyShapes
    {
        static int _count=0;
        public static String NewShapeID
        {
            get {
                _count++;
                return "ShapesIds-"+_count;
            }
        }

        public static IViewVO<int> createView(int id, String nome, List<IShapeVO> shapes) {
            ViewVO<int> view = new ViewVO<int>(new ViewVOId<int>(id) { Name = nome });
            foreach (IShapeVO shape in shapes)
                view.AddShape(shape);
            return view;
        }

        public static IViewVO<int> createHouse(int id, String nome, Point3d size, Point3d roofSize, Color baseColor,Color roofColor) {
            var shapes = new List<IShapeVO>();
            shapes.Add(new ShapeVO(new ShapeVOId(NewShapeID), new ShapeTypeVOId(ItemUC.ShapeTypeCube))
            {
                Position = new MapEngine.Point3d(),
                TypeModifiers = ItemUC.createCubeModifiers(new Point3d(new Point(0,0),size.Height/2), size, baseColor)
            });
            shapes.Add(new ShapeVO(new ShapeVOId(NewShapeID), new ShapeTypeVOId(ItemUC.ShapeTypePyramid))
            {
                Position = new MapEngine.Point3d(),
                TypeModifiers = ItemUC.createPyramidModifiers(new Point3d(new Point(0,0),size.Height), roofSize ,new Point(0,0),roofColor)
            });
            return createView(id, nome, shapes);
        }

        public static IViewVO<int> createTree(int id, String nome, Point3d troncoSize, Point copaSize)
        {
            var shapes = new List<IShapeVO>();
            shapes.Add(new ShapeVO(new ShapeVOId(NewShapeID), new ShapeTypeVOId(ItemUC.ShapeTypeCube))
            {
                Position = new MapEngine.Point3d(),
                TypeModifiers = ItemUC.createCubeModifiers(new Point3d(new Point(0, 0), troncoSize.Height / 2), troncoSize, Color.FromArgb(255, 139, 69, 19))
            });
            shapes.Add(new ShapeVO(new ShapeVOId(NewShapeID), new ShapeTypeVOId(ItemUC.ShapeTypeElipse))
            {
                Position = new MapEngine.Point3d(),
                TypeModifiers = ItemUC.createEllipseModifiers(new Point3d(new Point(0,0), (float)(troncoSize.Height/2 + copaSize.Y/2)),copaSize,Colors.Green)
            });
            return createView(id, nome, shapes);
        }

        public static IViewVO<int> createGrass(int id, String nome, Point size)
        {
            var shapes = new List<IShapeVO>();
            shapes.Add(new ShapeVO(new ShapeVOId(NewShapeID), new ShapeTypeVOId(ItemUC.ShapeTypeElipse))
            {
                Position = new MapEngine.Point3d(),
                TypeModifiers = ItemUC.createEllipseModifiers(new Point3d(new Point(0, 0), 0), size, Colors.Green)
            });
            return createView(id, nome, shapes);
        }
    }
}
